#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
char arr[10];
int cmp_arr(const void*p1,const void*p2)
{
	return *(char*)p1 - *(char*)p2;
}

int main()
{
	scanf("%s", arr);
	int la = strlen(arr); int rem = 0;
	int digit = 1;
	for (int i = 2; i <= la; i++) {
		digit *= i;
	}
	qsort(arr, la, sizeof(arr[0]), cmp_arr);
	do {
		printf("%s", arr);
		rem++;
		if (rem == digit)break;
		printf("\n");
	} while (next_permutation(arr, arr + la));
	return 0;
}